/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package traffic.light.simulator.town.unity;

/**
 *
 * 
 */
class TownUnityType3 extends TownUnity {

    public TownUnityType3(int positionX, int positionY, int townSize) {
        super(CrossRoadType.TYPE_3, positionX, positionY, townSize);
    }

    @Override
    public void generateCorrespondantUnity() {
        super.generateCorrespondantUnity();
        
        townElements[2][0] = new RoadElement(absoluteElementXPosition(0), absoluteElementYPosition(2), RoadType.LEFT);
        townElements[2][1] = new RoadElement(absoluteElementXPosition(1), absoluteElementYPosition(2), RoadType.LEFT);
        townElements[2][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(2), RoadType.LEFT);
        townElements[2][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(2), RoadType.LEFT);
        townElements[2][4] = new RoadElement(absoluteElementXPosition(4), absoluteElementYPosition(2), RoadType.LEFT);
        townElements[2][5] = new RoadElement(absoluteElementXPosition(5), absoluteElementYPosition(2), RoadType.LEFT);
        townElements[3][0] = new RoadElement(absoluteElementXPosition(0), absoluteElementYPosition(3), RoadType.RIGHT);
        townElements[3][1] = new RoadElement(absoluteElementXPosition(1), absoluteElementYPosition(3), RoadType.RIGHT);
        townElements[3][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(3), RoadType.RIGHT);
        townElements[3][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(3), RoadType.RIGHT);
        townElements[3][4] = new RoadElement(absoluteElementXPosition(4), absoluteElementYPosition(3), RoadType.RIGHT);
        townElements[3][5] = new RoadElement(absoluteElementXPosition(5), absoluteElementYPosition(3), RoadType.RIGHT);
        generateAccessibleElements();
        generateTL();
    }

    @Override
    protected void generateAccessibleElements() {
        if (positionX == townSize - 1 || positionX == 0) {
            this.isAccessibleForMovableEntities = true;
            if (positionX == 0) {
                this.accessibleTownElement = townElements[3][0];
            } else if (positionX == townSize - 1) {
                this.accessibleTownElement = townElements[2][5];
            }
        }
    }
}
